#!/usr/bin/env bash

get_soc_family() {
    case "$1" in
        a311d|s905y2|efi-amlogic)
            echo "amlogic"
            ;;
        rk*|op1|efi-rockchip)
            echo "rockchip"
            ;;
        efi|rootfs)
            echo "generic"
            ;;
        *)
            echo "Unrecognized SOC '$1'" >&2
            exit 1
            ;;
    esac
}

get_partition_type() {
    case "$1" in
        efi*)
            echo "gpt"
            return
            ;;
    esac

    local SOC_FAMILY="$(get_soc_family $1)"

    case "$SOC_FAMILY" in
        amlogic)
            echo "msdos"
            ;;
        rockchip|generic)
            echo "gpt"
            ;;
        *)
            echo "Unrecognized SOC_FAMILY '$1'" >&2
            exit 1
            ;;
    esac
}
